#!/usr/bin/env python
# coding=utf-8

def count_word(filename):
    """计算一个文件大概包含多少个单词"""
    try:
        with open(filename) as f_obj:
            contents = f_obj.read()
    except FileNotFoundError:
        #print("Sorry, the file {} is not exist!".format(filename))
        pass
    else:
        # 计算文件大概包含多少个单词
        words = contents.split()
        #print(words)
        num_words = len(words)
        print("The {} has about {} words.".format(filename, num_words))

#filename = 'alice.txt'
#count_word(filename)

filenames = ['alice.txt', 'Word-Study.txt', 'little_women.txt', 'Pride_and_Prejudice.txt']
for filename in filenames:
    count_word(filename)
